home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlib43 / mntlib / tcbreak.c < prev    next >
C/C++ Source or Header  |  1993-11-02  |  896b  |  44 lines

  1. /*
  2. Public domain termios tcsendbreak() for the MiNT library
  3. 10 October 1993 entropy@terminator.rs.itd.umich.edu -- first attempt
  4. */
  5.  
  6. #include <mintbind.h>
  7. #include <errno.h>
  8. #include <ioctl.h>
  9. #include <types.h>
  10. #include <termios.h>
  11.  
  12. int
  13. tcsendbreak(fd, duration)
  14.   int fd;
  15.   int duration;
  16. {
  17.   long oldmask;
  18.   long r;
  19.  
  20.   oldmask = Psigblock(~0L);
  21.   r = Fcntl((short) fd, (long) 0, TIOCSBRK);
  22.   if (r < 0) {
  23.     errno = (int) -r;
  24.     r = -1;
  25.   } else {
  26.     /* POSIX says a duration of 0 sends a break 250 to 500 ms long. */
  27.     if (duration == 0)
  28.       duration = 250;
  29.     /* POSIX does not specify the units for duration.
  30.        We use milliseconds.
  31.     */
  32.     (void) Fselect((short) duration, 0L, 0L, 0L);
  33.     r = Fcntl((short) fd, (long) 0, TIOCCBRK);
  34.     if (r < 0) {
  35.       errno = (int) -r;
  36.       r = -1;
  37.     } else {
  38.       r = 0;
  39.     }
  40.   }
  41.   (void) Psigsetmask(oldmask);
  42.   return (int) r;
  43. }
  44.